import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace ActivityCategoryApi {
  /** 活动分类 */
  export interface ActivityCategory {
    id?: number;
    communityId?: number;
    merchantId?: number;
    name?: string;
    icon?: string;
    sort?: number;
    createTime?: Date;
    updateTime?: Date;
  }
}

/** 查询活动分类分页 */
export function getActivityCategoryPage(params: PageParam) {
  return requestClient.get<PageResult<ActivityCategoryApi.ActivityCategory>>(
    '/cmt/activity-category/page',
    { params },
  );
}

/** 查询活动分类详情 */
export function getActivityCategory(id: number) {
  return requestClient.get<ActivityCategoryApi.ActivityCategory>(
    `/cmt/activity-category/get?id=${id}`,
  );
}

/** 新增活动分类 */
export function createActivityCategory(data: ActivityCategoryApi.ActivityCategory) {
  return requestClient.post('/cmt/activity-category/create', data);
}

/** 修改活动分类 */
export function updateActivityCategory(data: ActivityCategoryApi.ActivityCategory) {
  return requestClient.put('/cmt/activity-category/update', data);
}

/** 删除活动分类 */
export function deleteActivityCategory(id: number) {
  return requestClient.delete(`/cmt/activity-category/delete?id=${id}`);
}

/** 批量删除活动分类 */
export function deleteActivityCategoryList(ids: number[]) {
  return requestClient.delete(
    `/cmt/activity-category/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出活动分类 */
export function exportActivityCategory(params: any) {
  return requestClient.download('/cmt/activity-category/export-excel', { params });
}

/** 获取活动分类选项列表(用于下拉选择) */
export function getActivityCategoryOptions() {
  return requestClient.get<PageResult<ActivityCategoryApi.ActivityCategory>>(
    '/cmt/activity-category/page',
    { params: { pageNo: -1, pageSize: 10 } },
  );
}
